<?php
require_once 'application/constant/constant.php';
require_once 'application/library/cache/gcSession.php';
require_once 'application/library/helper/arrayHelper.php';

/**
 * gcUserDateHelper
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 */
class  userDataHelper{
    
    /**
     * 登录用户ID取得
     * getLoginUserId
     * @return  string  $val
     */
    public static  function getLoginUserId(){
        $userData=gcSession::getSession(sysConstant::USERDATA);
        $val = arrayHelper::getValue($userData,sysConstant::LOGINUSERID);
        //return $val;
        return "yizhipangzi";
    }

    /**
     * 登录用户番号取得
     * getLoginUserNO
     * @return  string
     */
    public static  function getLoginUserNo(){
        $userData=gcSession::getSession(sysConstant::USERDATA);
        $val = arrayHelper::getValue($userData,sysConstant::LOGINUSERNO);
        return $val;
    }

    /**
     * 登录用户名取得
     * getLoginUserName
     * @return  string  $val
     */
    public static function getLoginUserName(){
        $userData=gcSession::getSession(sysConstant::USERDATA);
        $val = arrayHelper::getValue($userData,sysConstant::LOGINUSERNAME);
                return "大雄";
        //return $val;
    }

    /**
     * 用户情报设定取得
     * setUserData
     * @param   array   $userData
     */
    public static function setUserData($userData){
        gcSession::setSession(sysConstant::USERDATA, $userData);
    }

    /**
     * 用户区分取得
     * getUserDistinguish
     * @return  string "1"-用户/"2"-顾客
     */
    public static function getUserDistinguish() {
        $userData=gcSession::getSession(sysConstant::USERDATA);
        return arrayHelper::getValue($userData, sysConstant::USER_DISTINGUISH);
    }

    /**
     * 用户部门权限取得
     * getUserDistinguish
     * @return  array
     */
    public static function getDepartment() {
        $userData=gcSession::getSession(sysConstant::USERDATA);
        return arrayHelper::getValue($userData, sysConstant::USERPERMISSIONS);
    }

    /**
     * 用户IpAddress取得
     * getUserIpAddress
     * @return  string  $realip
     */
    public static function getUserIpAddress(){
        if  (isset($_SERVER["HTTP_ORG_REMOTE_ADDR"])) {
            $realip  =  $_SERVER["HTTP_ORG_REMOTE_ADDR"];
        }else if  (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
            $realip  =  $_SERVER["HTTP_X_FORWARDED_FOR"];
        } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
            $realip  =  $_SERVER["HTTP_CLIENT_IP"];
        } else {
            $realip  =  $_SERVER["REMOTE_ADDR"];
        }
        return  $realip;
    }

    /**
     * 用户LOGO取得
     * getLogo
     * @return  string
     */
    public static function getLogo(){
        $userData=gcSession::getSession(sysConstant::USERDATA);
        return arrayHelper::getValue($userData, sysConstant::LOGO);
    }
}
